<template>
    <el-card class="b-tabs" shadow="never">
        <div class="tab" v-for="item in tabs" :key="item.value" :class="{ active: value === item.value }"
            @click="onClick(item)">{{ item.label }}</div>
        <slot></slot>
    </el-card>
</template>

<script>
export default {
    props: {
        tabs: {
            type: Array,
            default: () => []
        },
        value: {
            type: [String, Number],
            default: '0'
        }
    },
    data() {
        return {

        }
    },
    methods: {
        onClick(item) {
            this.$emit('input', item.value)
            this.$nextTick(() => {
                this.$emit('change', item)
            })
        }
    }
}
</script>

<style lang="scss" scoped>
.b-tabs {

    &:has(+.b-table),
    &:has(+.b-table-search) {
        border-radius: 4px 4px 0 0;

        :deep(.el-card__body) {
            padding-bottom: 15px;
        }
    }

    :deep(.el-card__body) {
        display: flex;
        align-items: center;
        color: #666;

        .tab {
            padding: 8px 8px 4px;
            border-bottom: 1px solid transparent;
            cursor: pointer;
            margin-right: 12px;

            &:hover,
            &.active {
                border-color: #3A7DFF;
                color: #3A7DFF;
                font-weight: bold;
            }
        }


        .el-button {
            margin-left: auto;
        }
    }

    &+:deep(.b-table),
    &+:deep(.b-table-search) {
        border-radius: 0 0 4px 4px;
    }
}
</style>